package network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

public class UdpDictServer extends UdpEchoServer{
    private HashMap<String,String> hashMap = new HashMap<>();
    public UdpDictServer(int port) throws SocketException {
        super(port);
        hashMap.put("cat","小猫");
        hashMap.put("chicken","小只因");
        hashMap.put("dog","小狗");
    }
    // start 方法完全从父类里继承下来
    // process 方法要进行重写, 加入自己的业务逻辑

    @Override
    public String process(String request){
        return hashMap.getOrDefault(request,"您查找的单词不存在");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(9090);
        server.start();
    }
}
